home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / AboveBelow.dxr / Internal_14_wheel barrel.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  1.7 KB  |  62 lines

  1. property obj, spriteNum, startpoint, endpoint, currentvector, ph, pv, vectorlist, vectorpos, displacement
  2.  
  3. on beginSprite me
  4.   obj = sprite(spriteNum)
  5.   vectorlist = [[-110, 0], [0, -210], [110, 0], [0, 210]]
  6.   vectorpos = 1
  7.   startpoint = [obj.locH.float, obj.locV.float]
  8.   endpoint = [startpoint[1] + vectorlist[vectorpos][1], startpoint[2] + vectorlist[vectorpos][2]]
  9.   displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
  10. end
  11.  
  12. on enterFrame me
  13.   if vectorpos = 1 then
  14.     ph = -1
  15.     pv = 0
  16.   else
  17.     if vectorpos = 2 then
  18.       ph = 0
  19.       pv = -1
  20.     else
  21.       if vectorpos = 3 then
  22.         ph = 1
  23.         pv = 0
  24.       else
  25.         if vectorpos = 4 then
  26.           ph = 0
  27.           pv = 1
  28.         end if
  29.       end if
  30.     end if
  31.   end if
  32.   obj.locH = obj.locH + ph
  33.   obj.locV = obj.locV + pv
  34.   startpoint = [obj.locH.float, obj.locV.float]
  35.   displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
  36.   thelength = sqrt((displacement[1] * displacement[1]) + (displacement[2] * displacement[2]))
  37.   if thelength < 0.5 then
  38.     vectorpos = vectorpos + 1
  39.     if vectorpos > 4 then
  40.       vectorpos = 1
  41.     end if
  42.     if vectorpos = 1 then
  43.       obj.rotation = 0
  44.     else
  45.       if vectorpos = 2 then
  46.         obj.rotation = 90
  47.       else
  48.         if vectorpos = 3 then
  49.           obj.rotation = 180
  50.         else
  51.           if vectorpos = 4 then
  52.             obj.rotation = -90
  53.           end if
  54.         end if
  55.       end if
  56.     end if
  57.     startpoint = [obj.locH.float, obj.locV.float]
  58.     endpoint = [startpoint[1] + vectorlist[vectorpos][1], startpoint[2] + vectorlist[vectorpos][2]]
  59.     displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
  60.   end if
  61. end
  62.